<template>
  <base-content>
    <BCRUD
      entity="User"
      :form="form"
      :columns="columns"
      :isGrid="false"
    ></BCRUD>
  </base-content>
</template>

<script>
import BCRUD from "components/BCRUD.vue";

export default {
  components: { BCRUD },
  data() {
    return {
      form: {
        // avatar: {
        //   is: "form-image",
        //   size: "100px",
        //   changeable: true
        // },
        id: {
          is: "q-input",
          label: "ID",
          readonly: true,
          whenShow: "upt"
        },
        nick: {
          is: "q-input",
          type: "text"
        },
        openid: {
          is: "q-input",
          type: "text"
        },
        name: {
          is: "q-input",
          type: "text",
          label: "姓名"
        },
        sex: {
          label: "性别",
          is: "q-select",
          emitValue: true,
          mapOptions: true,
          default: 0,
          options: [
            {
              label: "未知",
              value: 0
            },
            {
              label: "男",
              value: 1
            },
            {
              label: "女",
              value: 2
            }
          ]
        },
        birth: {
          is: "q-input",
          type: "text",
          label: "出生日期"
        },
        city: {
          is: "q-input",
          type: "text",
          label: "城市"
        },
        phone: {
          is: "q-input",
          type: "number",
          label: "手机号"
        },
        ip: {
          is: "q-input",
          type: "number",
          label: "IP",
          readonly: true
        },
        visit: {
          is: "q-input",
          type: "number",
          label: "最近访问时间",
          readonly: true
        },
        lastVisit: {
          is: "q-input",
          type: "number",
          label: "上次访问时间",
          readonly: true
        },
        status: {
          label: "用户状态",
          is: "q-select",
          emitValue: true,
          mapOptions: true,
          default: 0,
          options: [
            {
              label: "正常",
              value: 0
            },
            {
              label: "禁用",
              value: 1
            }
          ]
        },
        createdAt: {
          is: "q-input",
          type: "text",
          label: "创建时间",
          readonly: true
        },
        updatedAt: {
          is: "q-input",
          type: "text",
          label: "更新时间",
          readonly: true
        },
        deletedAt: {
          is: "q-input",
          type: "text",
          label: "删除时间",
          readonly: true
        }
        // roles: {
        //   is: "form-roles"
        // },
        // setting: {
        //   is: "form-setting"
        // }
      },
      columns: [
        {
          name: "mock",
          field: row => row.openid,
          is: "cell-mock",
          searchable: false
        },
        {
          name: "avatar",
          required: true,
          label: "画像",
          field: row => row.avatar,
          format: val => `${val}`,
          is: "form-avatar",
          searchable: false
        },
        {
          name: "id",
          required: true,
          label: "ID",
          field: row => row.id,
          format: val => `${val}`,
          sortable: true,
          searchModify: "@="
        },
        {
          name: "openid",
          required: true,
          label: "OpenID",
          field: row => row.openid,
          format: val => `${val}`,
          sortable: true,
          searchModify: "@="
        },
        {
          name: "phone",
          required: true,
          label: "手机号",
          field: row => row.phone,
          format: val => `${val}`,
          sortable: true,
          searchModify: "@="
        },
        {
          name: "nick",
          required: true,
          label: "昵称",
          field: row => row.nick,
          format: val => `${val}`,
          sortable: true,
          searchModify: "@="
        },
        {
          name: "name",
          required: true,
          label: "姓名",
          field: row => row.name,
          format: val => `${val}`,
          sortable: true,
          searchModify: "@="
        },
        {
          name: "sex",
          required: true,
          label: "性别",
          field: row => row.sex,
          format: val => `${["未知", "男", "女"][val]}`,
          sortable: true
        },
        {
          name: "status",
          required: true,
          label: "状态",
          field: row => row.status,
          format: val => `${["正常", "禁用"][val]}`,
          sortable: true
        },
        {
          name: "createdAt",
          required: true,
          label: "创建时间",
          field: row => row.createdAt,
          format: val => `${val}`
        },
        {
          name: "updatedAt",
          required: true,
          label: "更新时间",
          field: row => row.updatedAt,
          format: val => `${val}`
        }
      ]
    };
  }
};
</script>

<style></style>
